home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Developer Connection Student Program
/
ADC Tools Sampler CD Disk 3 1999.iso
/
Documentation
/
Books
/
Learn Java on the Macintosh
/
Learn Java Projects
/
12.01 - floating pt
/
FloatingPt.java
< prev
next >
Wrap
Text File
|
1996-04-22
|
835b
|
38 lines
/* -------------------------------------------------------------
This applet uses floating point numbers as instance variables.
Java's classes: Applet (applet)
System (lang)
Custom classes: FloatingPt
Triangle
------------------------------------------------------------- */
public class FloatingPt extends java.applet.Applet {
public void init() {
Triangle t1 = new Triangle();
t1.base = 9;
t1.height = 15;
Triangle t2 = new Triangle();
t2.base = 14.232;
t2.height = 3.2947;
System.out.println("area of t1 is " + t1.area());
System.out.println("area of t2 is " + t2.area());
}
}
class Triangle {
double base;
double height;
double area() {
return base * height / 2.0;
}
}